home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group99a.txt
/
000168_icon-group-sender _Thu Jul 29 12:28:22 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id MAA02945
for icon-group-addresses; Thu, 29 Jul 1999 12:26:12 -0700 (MST)
Message-Id: <199907291926.MAA02945@baskerville.CS.Arizona.EDU>
From: "Frank Lhota" <lhotaf@lexma.meitech.com>
To: <icon-group@optima.CS.Arizona.EDU>
Subject: How to Bring Back the Old basename
Date: Thu, 29 Jul 1999 12:10:19 -0400
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Nevin Liber has a good point regarding basename. Even if the latest version
is closer to the original intentions, as well as the closer to what the name
suggests, there may be many applications dependant on the old behavior. To
keep these applications from breaking, we need to retain the old, quirky
behavior. This is unfortunate for new developers who would rather have
something closer to the Unix utility.
Has anyone else noticed how superfluous the second parameter to the old
basename is? The old basename chops off the extension whether or not the
second parameter is specified, and whether or not it is present, so when
does specifying an extension make a difference?
The best option for now may be to fix basename to return the old behavior,
and also update the documentation to clarify the quirk. Here is my proposal:
############################################################################
#
# File: basename.icn
#
# Subject: Procedures to produce base name of a file
#
# Author: Ralph E. Griswold
#
# Date: September 22, 1998
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# Contributor: Charles Shartsis
#
############################################################################
#
# This procedure is based on the UNIX basename(1) utility. It strips off
# any path information and removes the specified suffix, if present.
#
# If no suffix is provided, or if the suffix is not at the end of the name,
# the portion of the name up to the first "." is returned.
#
# It should work under UNIX, MS-DOS, and the Macintosh.
#
############################################################################
procedure basename(name, suffix) #: base name of file
local base
name ? {
while tab ( upto('/\\:') + 1 ) # get rid of path, if any
if ( base := tab ( -*\suffix ) ) & =suffix
then return base
else return tab ( find ( "." ) | 0 )
}
end